{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set chapter = chapter|default(null) %}

{% block title %}
  {% if chapter %}{{'编辑'|trans}}{% else %}{{'添加'|trans}}{% endif %}{% if type == 'unit' %}{% if setting('default.part_name') %}{{ setting('default.part_name')|default('节'|trans) }}{% else %}{{'节'|trans}}{% endif %}{% else %}{% if setting('default.chapter_name') %}{{ setting('default.chapter_name')|default('章'|trans) }}{% else %}{{'章'|trans}}{% endif %}{% endif %}
{% endblock %}
{% block body %}

<form id="course-chapter-form" class="form-horizontal" method="post" {% if parentId is defined%}data-parentId="{{parentId}}" {% endif %}
  {% if chapter %}
	  action="{{ path('course_manage_chapter_edit', {courseId:course.id, chapterId:chapter.id}) }}"
	{% else %}
	  action="{{ path('course_manage_chapter_create', {id:course.id}) }}"
  {% endif %}
  >
  <div class="row form-group">
    <div class="col-md-3 control-label">
      {% if type == 'unit' %}
        <label for="chapter-title-field">{% if setting('default.part_name') %}{{ setting('default.part_name')|default('节'|trans) }}{% else %}{{'节'|trans}}{% endif %}{{'标题'|trans}}</label>
      {% else %}
        <label for="chapter-title-field">{% if setting('default.chapter_name') %}{{ setting('default.chapter_name')|default('章'|trans) }}{% else %}{{'章'|trans}}{% endif %}{{'标题'|trans}}</label>
      {% endif %}
    </div>
    <div class="col-md-8 controls"><input id="chapter-title-field" type="text" name="title" value="{{ field_value(chapter, 'title') }}" class="form-control"></div>
  </div>
  <input type="hidden" name="type" value="{{ type }}">
</form>

<script>app.load('course-manage/chapter-modal')</script>

{% endblock %}

{% block footer %}
    <button type="button" class="btn btn-link" data-dismiss="modal">{{'取消'|trans}}</button>
    <button id="course-chapter-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary" data-toggle="form-submit" data-target="#course-chapter-form" data-chapter="}{{ default.chapter_name|default('章'|trans) }}" data-part="}{{ default.part_name|default('节'|trans) }}">{% if chapter %}{{'保存'|trans}}{% else %}{{'添加'|trans}}{% endif %}</button>
{% endblock %}

{% set hideFooter = true %}
